﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
using WRS.Data;

// The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229

namespace WRS
{
    /// <summary>
    /// A page that displays an overview of a single group, including a preview of the items
    /// within the group.
    /// </summary>
    public sealed partial class Page3 : WRS.Common.LayoutAwarePage
    {

        public string title;
        public Page3()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property provides the group to be displayed.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Assign a bindable group to this.DefaultViewModel["Group"]
            // TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"]

            var group = (SampleDataGroup)e.Parameter;
            this.DefaultViewModel["Group"] = group;
            this.DefaultViewModel["Items"] = group.Items;
            //this.SaveState(e);
        }
        void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            // Navigate to the appropriate destination page, configuring the new page
            // by passing required information as a navigation parameter
            if (pageTitle.Text == "Animals")
            {
                title = pageTitle.Text;
                this.Frame.Navigate(typeof(Read), title);
            }
            else if (pageTitle.Text == "Sports")
            {
                title = pageTitle.Text;
                this.Frame.Navigate(typeof(Read), title);
            }


            
        }

        private void Background_Loaded(object sender, RoutedEventArgs e)
        {
            if (DateTime.Now.Hour >= 6 && DateTime.Now.Hour < 12)
            {
                ImageBrush bg = new ImageBrush();
                bg.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Morning.png", UriKind.Absolute));
                Background.Background = bg;
            }
            else if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18)
            {
                ImageBrush bg = new ImageBrush();
                bg.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Noon.png", UriKind.Absolute));
                Background.Background = bg;
            }
            else
            {
                ImageBrush bg = new ImageBrush();
                bg.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Night.png", UriKind.Absolute));
                Background.Background = bg;
            }

        }
    }
}
